import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:wu_you/utils/utils.dart';

class TipsDialogView extends StatelessWidget{
  final String content;
  final String title;
  final String background;
  TipsDialogView({Key key,this.content,this.title,this.background}) :super(key: key);
  @override
  Widget build(BuildContext context) {
    return Material(
        color: Colors.transparent,
        child: WillPopScope(
            child: Center(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  mainAxisSize: MainAxisSize.min,
                  children: [
                    Padding(
                      padding: EdgeInsets.only(left: 32, right: 32, bottom: 8),
                      child: AspectRatio(
                          aspectRatio: 1,
                          child: Container(
                            margin: EdgeInsets.only(bottom: 8),
                            decoration: BoxDecoration(
                              image: DecorationImage(
                                image: AssetImage(
                                  Utils.getImgPath(background),
                                ),
                                fit: BoxFit.fill,
                              ),
                            ),
                            child: Stack(
                              children: [
                                Positioned(
                                  left: 32,
                                  top: 32,
                                  child: Text(title,style: TextStyle(color: Colors.white,fontSize: 25),)
                                ),
                                Align(
                                  alignment: Alignment.centerLeft,
                                  child: Padding(
                                    padding: EdgeInsets.only(left: 32,right: 30,top: 30),
                                    child: Container(
                                      height: 120,
                                      child: SingleChildScrollView(
                                          child:  Text(
                                            content,
                                          ),))
                                  ),
                                ),
                                Align(
                                  alignment: Alignment.bottomCenter,
                                  child: Padding(
                                      padding: EdgeInsets.only(bottom: 10),
                                      child: ElevatedButton(
                                        child: Text("知道了"),
                                        onPressed: (){
                                          Navigator.pop(context);
                                        },
                                        style: ButtonStyle(
                                          minimumSize: MaterialStateProperty.all(Size(150, 40)),
                                          shape: MaterialStateProperty.all(RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)))),
                                      )
                                  ),
                                ),
                              ],
                            ),
                          )
                      ),
                    ),
                    // CloseButton(
                    //   color: Colors.white,
                    // ),
                  ],
                )
            )
        )
    );
  }
}
class ShowTipsDialog {

  static show(BuildContext context,String title,String content,String bg){
    showDialog(
      context: context,
      builder: (context) {
        return TipsDialogView(content: content,title:title,background: bg,);
      },
    );
  }

}